import 'package:flutter/material.dart';
import 'package:flutterapptest2/StatefulGroup.dart';
import 'package:flutterapptest2/animation_route.dart';
import 'package:flutterapptest2/flutter_widget_lifecycle.dart';
import 'package:flutterapptest2/hero_animation_route.dart';
import 'package:flutterapptest2/images_riute.dart';
import 'package:flutterapptest2/layout_flutter.dart';
import 'package:flutterapptest2/lunch_page.dart';
import 'package:flutterapptest2/photo_app.dart';
import 'package:flutterapptest2/shapefile_loading.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme:
          ThemeData(primarySwatch: Colors.pink, brightness: Brightness.light),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>{
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView(
        children: <Widget>[
          _widget(
              title: 'Statefule组件',
              subTitle: 'Statefule基础组件联系',
              route: StatefulGroup()),
          _widget(
              title: 'flutter布局',
              subTitle: 'flutter布局相关组件',
              route: FlutterLayoutPage()),
          _widget(
            title: 'url_launch使用',
            subTitle: '使用url_launch打开第三方应用',
            route: LunchPage(),
          ),
          _widget(
            title: 'stafu生命周期',
            subTitle: 'flutter控件的生命周期',
            route: FlutterWidgetLifecycle(),
          ),
          _widget(
            title: '拍照demo',
            subTitle: '拍照，选择照片一个demo',
            route: PhotoApp(),
          ),
          _widget(
            title: '图片练习',
            subTitle: '图片控件的练习',
            route: ImagesRoute()
          ),
          _widget(
              title: '动画练习',
              subTitle: '动画练习',
              route: AnimationRoute()
          ),
          _widget(
              title: 'Hero动画',
              subTitle: 'Hero动画练习',
              route: HeroAnimationRoute()
          ),
          _widget(
            title: '网络测试',
            subTitle: '自己写的后台接口测试',
            route:ShapeFileRoute()
          )
        ],
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  Widget _widget({String title, String subTitle, route}) {
    return Column(
      children: <Widget>[
        ListTile(
          title: Text(title),
          subtitle: Text(subTitle),
          onTap: () {
            Navigator.push(context, MaterialPageRoute(builder: (context) {
              return route;
            }));
          },
          dense: true,
        ),
        Divider(
          height: 1,
        ),
      ],
    );
  }
}
